package com.jnc.core.base.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jnc.common.base.BaseReq;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.Date;
import java.util.List;

@Setter
@Getter
public class User extends BaseReq {
    private static final long serialVersionUID = 1L;

    private Integer userId;

    private String loginName;

    private String userName;

    private String password;

    private String sex;

    @JsonFormat(pattern="yyyy-MM-dd")
    private Date birthday;

    private String phone;

    private String address;

    private String email;

    private Integer status;

    private String remark;

    private Date updateTime;

    private Date createTime;

    private List<Integer> roles;

    private Boolean rememberMe;

    private String newPassword;   //新密码
    private String confirmPassword;  //确认新密码

    public boolean isAdmin(){
        return this.userId != null && this.userId == 1;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("userId", userId)
                .append("loginName", loginName)
                .append("userName", userName)
                .append("password", password)
                .append("sex", sex)
                .append("birthday", birthday)
                .append("phone", phone)
                .append("address", address)
                .append("email", email)
                .append("status", status)
                .append("remark", remark)
                .append("updateTime", updateTime)
                .append("createTime", createTime)
                .toString();
    }
}